package com.ng.framework.persistence;

import java.util.List;

import org.springframework.stereotype.Service;

import com.ng.framework.persistence.NGSearchParameter.Type;
import com.ng.framework.persistence.NGSearchParameter.UnaryOperation;

@Service
public class NGPropertyService extends NGGenericPersistenceJPA<NGProperty> {

	public static final String PERIODO_ACTUAL = "PERIODO_ACTUAL";

	public static final String COMISION_COBRADOR = "COMISION_COBRADOR";

	public static final String DIAS_X_SEMANA = "DIAS_X_SEMANA";

	public static final String ATRASO_LEVE_DIAS = "ATRASO_LEVE_DIAS";

	public static final String ATRASO_GRAVE_DIAS = "ATRASO_GRAVE_DIAS";

	public String getProperty(String name) {

		NGSearchParameter pName = new NGSearchParameter(NGProperty.class,
				"name", name, Type.STRING, UnaryOperation.EQUALS);

		NGSearchCriteria criteria = new NGSearchCriteria(null, null, null, null);

		criteria.addNGSearchParameter(pName);

		List<NGProperty> ngProperties = getAll(criteria);

		return ngProperties.isEmpty() ? null : ngProperties.get(0).getValue();

	}

}
